﻿using System;
using System.Threading.Tasks;
using Windows.Storage;

namespace Infos.InterviewApp.Manager
{
    public class ManagerRoamingState
    {
        public StorageFolder storageFolder;
        public const string filename = "version.txt";

        public async Task Scrivi(string versione)
        {
            storageFolder = ApplicationData.Current.RoamingFolder;
            StorageFile file = await storageFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
            await FileIO.WriteTextAsync(file, versione.ToString());
        }

        public async Task<String> Leggi()
        {
            try
            {
                storageFolder = ApplicationData.Current.RoamingFolder;
                StorageFile file = await storageFolder.GetFileAsync(filename);
                return await FileIO.ReadTextAsync(file);
            }
            catch (Exception ex)
            {
                return "1";
            }
        }

    }
}
